using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.ExpressApp.Security;

namespace TestPermission.Module
{
    public partial class ViewController1 : ViewController
    {
        public ViewController1()
        {
            InitializeComponent();
            RegisterActions(components);
            simpleAction1.TargetObjectType = typeof(DomainObject1);
            simpleAction2.TargetObjectType = typeof(DomainObject1);
        }

        private void simpleAction2_Execute(object sender, SimpleActionExecuteEventArgs e)
        {

        }

        private void simpleAction1_Execute(object sender, SimpleActionExecuteEventArgs e)
        {

        }

        private void ViewController1_Activated(object sender, EventArgs e)
        {
            this.simpleAction1.Enabled.SetItemValue("ActionObject", SecuritySystem.IsGranted(new ActionAccessPermission(this.simpleAction1.Id, ObjectAccessModifier.Allow)));
            this.simpleAction2.Enabled.SetItemValue("ActionObject2", SecuritySystem.IsGranted(new ActionAccessPermission(this.simpleAction2.Id, ObjectAccessModifier.Allow)));
        }
    }
}
